package com.cskaoyan.user.dal.entitys;

import lombok.Data;
import lombok.ToString;
import tk.mybatis.mapper.annotation.KeySql;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
import java.util.Objects;

@Table(name = "tb_member")
@Data
@ToString
public class Member {
    @Id
    @KeySql(useGeneratedKeys = true)
    private Long id;

    /**
     * 用户名
     */
    private String username;

    /**
     * 密码，加密存储
     */
    private String password;

    /**
     * 注册手机号
     */
    private String phone;

    /**
     * 注册邮箱
     */
    private String email;

    private Date created;

    private Date updated;

    private String sex;

    private String address;

    private Integer state;

    /**
     * 头像
     */
    private String file;

    private String description;

    /**
     * 积分
     */
    private Integer points;

    /**
     * 余额
     */
    private Double balance;

    /**
     *  是否激活,默认值N，激活Y
     */
    @Column(name = "isVerified")
    private String isVerified;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Member member = (Member) o;
        return Objects.equals(id, member.id) ||
                Objects.equals(username, member.username) ||
                Objects.equals(phone, member.phone) ||
                Objects.equals(email, member.email) ;
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, username, password, phone, email, created, updated, sex, address, state, file, description, points, balance, isVerified);
    }
}